import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parent.parent.absolute()))
from Test import testcase, check
from core.Pos import Pos, PosSet
from core.BuiltinChess.Pawn import Pawn
from core.Board import Board
b = Board()


def init_board():
    b.board[Pos(0, 1, 1)] = Pawn(Pos(0, 1, 1), 1, board=b)


if __name__ == "__main__":
    init_board()
    b.board[Pos(1, 1, 1)] = Pawn(Pos(1, 1, 1), 2, board=b)
    print(b.to_json())
    testcase(b.board[Pos(0, 1, 1)].pos.x_right_up().x_right_up(), "(0, 2, 2)")
    testcase(b.get_chess(Pos(0, 1, 1)).type, "Pawn")
    testcase(b.can_kill(b.get_chess(Pos(0, 1, 1)), Pos(1, 1, 1)), "True")
    testcase(b.try_move(1, Pos(0, 1, 1), Pos(1, 1, 1)), "True")
    testcase(b.board, "{(1, 1, 1): <Pawn of player 1>}")
    testcase(b.has_chess(Pos(1, 1, 1)), "True")
    testcase(b.score, "[0, 1, 0, 0]")
    testcase(Pos(0, 6, 5).toNAR(), "(8, 'j', 'vii')")
    testcase(Pos(1, 3, 6).toNAR(), "(7, 'i', 'x')")
    testcase(Pos.fromNAR(9, 'i', 'viii'), "(1, 5, 4)")
    check()
    # print(b.board[(0,1,1)].pos)
